package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/7.
 */
@HttpInlet(Conn.INLET_API_COMMISSION_EXTRACTED)
public class GetApiYiTiXian extends BaseAsyGet<GetApiYiTiXian.Info> {

    public String userid, starttime, endtime;

    public GetApiYiTiXian(AsyCallBack<GetApiYiTiXian.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");

        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();
            JSONArray array = jsonObject.optJSONArray("data");
            for (int i = 0; i < array.length(); i++) {

                JSONObject o = array.optJSONObject(i);
                Data d = new Data();

                d.id = o.optString("id");
                d.price = o.optString("price");
                d.client = o.optString("client");
                d.products = o.optString("products");
                d.posttime = o.optString("posttime");
                d.total = o.optString("total");

                info.dataList.add(d);
            }
            return info;
        }


        return null;
    }

    public static class Info {

        public List<Data> dataList = new ArrayList<>();
    }

    public static class Data {

        //        "id": "1",
//                "price": "100.00",
//                "settime": "1462563032",
//                "client": "张某某",
//                "products": "车险"
        public String id, price, client, products, posttime, total;
    }
}
